//
// Created by 高森森 on 2022/10/10.
//

#ifndef LEETCODE_SOLUTION_19_H
#define LEETCODE_SOLUTION_19_H
#include<bits/stdc++.h>
using namespace std;

class solution_19 {
public:
    int maxRotateFunction(vector<int>& nums) {
        int f0=0;
        int sum=0;
        int n=nums.size();
        for(int i=0;i<n;i++){
            f0+=i*nums[i];
            sum+=nums[i];
        }
        int m=f0;
        for(int i=1;i<n;i++){
            f0=f0+sum-n*nums[n-i];
            m=max(m,f0);
        }
        return m;
    }
};


#endif //LEETCODE_SOLUTION_19_H
